package com.yiwei.zhh.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yiwei.zhh.R;
import com.yiwei.zhh.adapter.base.BaseLViewHolder;
import com.yiwei.zhh.adapter.base.BaseListAdapter;
import com.yiwei.zhh.model.PhonePwdModel;

import java.util.List;

public class PhonePwdAdapterNew extends BaseListAdapter<PhonePwdModel.Data> {
    private LayoutInflater inflater;
    private List<PhonePwdModel.Data> list;
    private Context context;

    public PhonePwdAdapterNew(Context context, List<PhonePwdModel.Data> list) {
        super(context, list);
        this.list = list;
        this.context = context;
        inflater = LayoutInflater.from(context);
    }


    @Override
    public View bindView(int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.phone_pwd_items, null);
        }

        TextView title = BaseLViewHolder.get(convertView, R.id.tv_title);
        TextView text1 = BaseLViewHolder.get(convertView, R.id.text1);
        TextView text2 = BaseLViewHolder.get(convertView, R.id.text2);
        TextView text3 = BaseLViewHolder.get(convertView, R.id.text3);
        TextView text4 = BaseLViewHolder.get(convertView, R.id.text4);

        title.setText(list.get(position).getOperator());

        if (list.get(position).getMethods().length > 0) {
            text1.setVisibility(View.VISIBLE);
            text1.setText(context.getString(R.string.way_one) + "  " + list.get(position).getMethods()[0]);
        }
        if (list.get(position).getMethods().length > 1) {
            text2.setVisibility(View.VISIBLE);
            text2.setText(context.getString(R.string.way_two) + "  " + list.get(position).getMethods()[1]);
        }
        if (list.get(position).getMethods().length > 2) {
            text3.setVisibility(View.VISIBLE);
            text3.setText(context.getString(R.string.way_three) + "  " + list.get(position).getMethods()[2]);
        }
        if (list.get(position).getMethods().length > 3) {
            text4.setVisibility(View.VISIBLE);
            text4.setText(context.getString(R.string.way_four) + "  " + list.get(position).getMethods()[3]);
        }

        return convertView;
    }



}


